package com.assignwork.vo;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import lombok.Data;
import org.springblade.core.tool.utils.DateUtil;
import org.springframework.format.annotation.DateTimeFormat;

import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.List;

@Data
public class ThroughputForecastVO {

    @JsonSerialize(using = ToStringSerializer.class)
    private Long id;
    private String shipName;
    private String voyage;
    @JsonSerialize(using = ToStringSerializer.class)
    private Long sourceId;
    private String tradeType;
    private String tradeTypeName;
    private String impExp;
    private String impExpName;
    private Integer isFinish;
    private String shipBerthKey;
    private String shipBerthName;
    private String cargoType;
    private String cargoTypeName;
    private BigDecimal planTon;
    @JsonFormat(pattern = DateUtil.PATTERN_DATE)
    @DateTimeFormat(pattern = DateUtil.PATTERN_DATE)
    private LocalDate planDate;
    @JsonFormat(pattern = DateUtil.PATTERN_DATETIME)
    @DateTimeFormat(pattern = DateUtil.PATTERN_DATETIME)
    private LocalDateTime begTime;
    @JsonFormat(pattern = DateUtil.PATTERN_DATETIME)
    @DateTimeFormat(pattern = DateUtil.PATTERN_DATETIME)
    private LocalDateTime endTime;

    private BigDecimal visaTon;
    private BigDecimal lastTon;
    @JsonSerialize(using = ToStringSerializer.class)
    private Long shipowner;
    private String shipownerName;

    private List<ThroughputForecastItemVO> cargoTon;

    public String getPlanTonStr() {
        if (planTon != null) {
            return planTon.stripTrailingZeros().toPlainString();
        }
        return "";
    }

    public String getVisaTonStr() {
        if (visaTon != null) {
            return visaTon.stripTrailingZeros().toPlainString();
        }
        return "";
    }

    public String getLastTonStr() {
        if (lastTon != null) {
            return lastTon.stripTrailingZeros().toPlainString();
        }
        return "";
    }
}
